﻿using System.Xml.Linq;

namespace Grinder.Fb2
{
    public sealed class Author
    {
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string MiddleName { get; set; }

        public Author(XContainer element)
        {
            // Parse First Name
            var el = element.Element(Constants.Xmlns + "first-name");
            FirstName = (el == null) ? "" : el.Value;

            // Parse Last Name
            el = element.Element(Constants.Xmlns + "last-name");
            LastName = (el == null) ? "" : el.Value;

            // Parse Middle Name
            el = element.Element(Constants.Xmlns + "middle-name");
            MiddleName = (el == null) ? "" : el.Value;
        }        
    }
}
